// http://marakana.com/forums/android/examples/49.html
// TODO: ver NDK with clang

#include <iostream>
#include <string>
#include <jni.h>
#include <android/log.h>
//#include <stdio.h>
//#include <string.h>

#include "jnipp.hpp"


#define DEBUG_TAG "NDK_AndroidNDK1SampleActivity"


//***************** Native functions *****************
void hello_log( std::string const& str )
{
	__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "FER NDK:LC: [%s]", str.c_str() );

	//auto xxx = [](){ std::cout << "hello"; };
	//xxx();
}

void hello_log_2( std::string const& str, std::string const& str2 )
{
	__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "FER NDK:LC: [%s]", str.c_str() );
	__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "FER NDK:LC: [%s]", str2.c_str() );
}


void test_cpp11()
{
	//auto xxx = [](){ std::cout << "hello"; };
	//xxx();
}



//***************** Managed (Java) wrapped functions *****************


//extern "C"
//void Java_com_mamlambo_sample_ndk1_AndroidNDK1SampleActivity_helloLog( JNIEnv * env, jobject obj, jstring logThis )
//{
//	//std::cout << "fer";
//	hello_log( jnipp::from_java_string(env, logThis) );
//}

JNI_FUNCTION(com_mamlambo_sample_ndk1, AndroidNDK1SampleActivity,
	helloLog, hello_log, void,
	(jstring, logThis)
)

//TODO: el nombre del parametro no tiene sentido...
JNI_FUNCTION(com_mamlambo_sample_ndk1, AndroidNDK1SampleActivity,
	helloLog2, hello_log_2, void,
	(jstring, logThis)
	(jstring, logThis2)
)










//extern "C"
//jstring Java_com_mamlambo_sample_ndk1_AndroidNDK1SampleActivity_getString( JNIEnv * env, jobject obj, jint value1, jint value2 )
//{
	//const char *szFormat = "The sum of the two numbers is: %i";
	//char *szResult;

	//// add the two values
	//jlong sum = value1 + value2;

	//// malloc room for the resulting string
	//szResult = (char*) malloc(sizeof(szFormat) + 20);

	//// standard sprintf
	//sprintf(szResult, szFormat, sum);

	//// get an object string
	//jstring result = env->NewStringUTF(szResult);

	//// cleanup
	//free(szResult);

	//return result;
//}






//---------------------------------------------------------------------------------------------------------------------

